package com.sun.common;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sun.pojo.UmsResource;
import com.sun.vo.PageVo;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class MsResult {
    private int code;
    private String message;
    private Object data;

    public static MsResult isOkMessage(String message) {
        MsResult ms = new MsResult();
        ms.code = 200;
        ms.message = message;
        return ms;
    }

    public static MsResult isOkMData(String message,Object data) {
        MsResult ms = new MsResult();
        ms.code = 200;
        ms.message = message;
        ms.data = data;
        return ms;
    }

    public static MsResult isOkData(Object data) {
        MsResult ms = new MsResult();
        ms.code = 200;
        ms.data = data;
        return ms;
    }

    public static MsResult isFail(String message) {
        MsResult ms = new MsResult();
        ms.code = 500;
        ms.message = message;
        return ms;
    }

    public static MsResult isOkDataPage(IPage<UmsResource> page) {
        PageVo vo = PageVo.pageToVo(page);
        return MsResult.isOkData(vo);

    }
}
